<?php

declare(strict_types=1);

/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

use Hyperf\Stringable\Str;
use function Hyperf\Support\env;

$prefix = env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'hyperf-app'), '_') . '_database:');

return [
    'default' => [
        'host' => env('REDIS_HOST', 'localhost'),
        'auth' => env('REDIS_AUTH', null),
        'port' => (int)env('REDIS_PORT', 6379),
        'db' => (int)env('REDIS_DB', 0),
        'pool' => [
            'min_connections' => 1,
            'max_connections' => 10,
            'connect_timeout' => 10.0,
            'wait_timeout' => 3.0,
            'heartbeat' => 10,
            'max_idle_time' => (float)env('REDIS_MAX_IDLE_TIME', 60),
        ],
        'options' => [ // Redis 客户端 Options, 参照 https://github.com/phpredis/phpredis#setoption
            \Redis::OPT_PREFIX => $prefix,
            'prefix' => $prefix,// v3.0.38 或更高版本
        ],
    ],
];
